package cn.youth996.springcloud.controller;

import cn.youth996.springcloud.service.PaymentService;
import cn.youth996.springcloud.entities.CommonResult;
import cn.youth996.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Zhan Xinjian
 * @date 2021/3/4
 */
@RestController
@Slf4j
@RequestMapping("/payment")
public class PaymentController {
    @Resource
    private PaymentService paymentService;
    @PostMapping("/save")
    public CommonResult save(@RequestBody Payment payment) {
        paymentService.save(payment);
        return new CommonResult(200,"插入数据库成功");
    }

    @GetMapping("/get/{id}")
    public CommonResult getPaymentById(@PathVariable("id") Long id) {
        Payment payment = paymentService.getPaymentById(id);
        return new CommonResult(200, "查询成功", payment);
    }
}
